package at.jku.se.fastsell.gui;

import com.vaadin.navigator.View;
import com.vaadin.navigator.ViewChangeListener.ViewChangeEvent;
import com.vaadin.ui.Alignment;
import com.vaadin.ui.Button.ClickListener;
import com.vaadin.ui.Panel;
import com.vaadin.ui.VerticalLayout;
import com.vaadin.ui.Button.ClickEvent;

public class EntryView extends VerticalLayout implements View, IViewStatus {

	public static final String NAME = "entry";

	private static final long serialVersionUID = 1L;

	private Panel mainPanel;

	// ----------------------------------------------------------------------------------

	public EntryView() {
		buildMainLayout();

		this.setSizeFull();
		this.setSpacing(true);

		this.addComponent(mainPanel);
		this.setComponentAlignment(mainPanel, Alignment.MIDDLE_CENTER);
	}

	private void buildMainLayout() {
		mainPanel = new Panel("Welcome!");
		mainPanel.setWidth("480px");
	}

//	@Override
	public void enter(ViewChangeEvent event) {
		mainPanel.setContent(new LoginComponent(new ClickListener() {

			private static final long serialVersionUID = 1L;

//			@Override
			public void buttonClick(ClickEvent event) {
				mainPanel.setContent(new RegisterComponent());
			}
		}));

	}

//	@Override
	public void setInactive() {
		// nothing to do...
	}

//	@Override
	public String getName() {
		return NAME;
	}
}